﻿<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">修改公告</h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">公告管理</a>
                </li>
                <li class="breadcrumb-item active">修改公告</li>
            </ol>
        </div>
        <div class="page-content">
            <div class="panel">
                <div class="panel-body">
                    <div class="example-wrap">
                        <div class="example">
                            <div id="div1" class="form-group">
                                <label class="control-label" for="inputInlinePassword">公告内容</label>
                                <textarea id="TextArea3" rows="5" cols="50" class="form-control"></textarea>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-1">
                                    <input type="button" id="TianJia" onclick="Update()" class="btn btn-block btn-info" value="修改" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <input type="text" hidden="hidden" id="zhuanduiid" />
    </div>
</div>
<script>
    $(document).ready(function () {
        $("#SpanGongGao").click();
        var shu = getQuery("id");
        $("#zhuanduiid").val(shu);
        morenzhi();
    });

    function morenzhi() {
        var id = $("#zhuanduiid").val();
        $.ajax({
            type: 'post',
            url: '../GongGao/Getid',
            async: false,
            dataType: 'json',
            data: { id: id },
            success: function (datea) {
                $("#TextArea3").val(datea.neiRong);
            },
        })
    }

    function Update() {
        var id = $("#zhuanduiid").val();
        var neirong = $("#TextArea3").val();
        if (neirong == "") {
            alert("内容不能为空");
        }  else {
            $.ajax({
                type: 'post',
                url: '../GongGao/Update',
                dataType: 'text',
                async: true,
                data: { id: id, neirong: neirong},
                success: function (result) {
                    if (result == "1") {
                        alert("修改成功");
                        location.href = "../GongGao/GongGaoList";
                    } else {
                        alert("修改失败");
                    }
                }
            });
        }
    }

    function getQuery(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]); return null;
    }

</script>